extends KinematicBody2D

enum Gun{big,small}
var gun_type 
const speed = 5000
var vec = Vector2(0,0)
onready var gts = preload("res://Object/Gts.tscn")
onready var zidan = preload("res://Object/Zidan.tscn")

func _process(delta):
	if Input.is_action_pressed("ui_left"):
		vec.x = -1
	elif Input.is_action_pressed("ui_right"):
		vec.x = 1
	elif Input.is_action_pressed("ui_up"):
		vec.y = -1
	elif Input.is_action_pressed("ui_down"):
		vec.y = 1
	else:
		vec = Vector2(0,0)
	if Input.is_action_pressed("x"):
		self.scale += Vector2(0.1,0.1)*delta
	elif Input.is_action_pressed("z"):
		self.scale -= Vector2(0.1,0.1)*delta
	move_and_slide(vec*delta*speed)
	look_at(get_global_mouse_position())
	pass

func _input(event):
	if Input.is_action_pressed("g"):
		var g = gts.instance()
		g.position = self.position
		get_parent().add_child(g)
	if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT:
		var target_pos = get_global_mouse_position()
		var z = zidan.instance()
#		z.position = self.position
#		get_parent().add_child(z)
		add_child(z)
	pass
